package com.xhu.service.impl;

import com.xhu.bean.pojo.SalesPlan;
import com.xhu.dao.SpDao;
import com.xhu.dao.impl.SpDaoImpl;
import com.xhu.service.SpService;
import com.xhu.utils.ResultData;

import javax.servlet.http.HttpServletRequest;
import java.sql.SQLException;
import java.util.List;

public class SpServiceImpl implements SpService {

    private SpDao spDao=new SpDaoImpl();
    @Override
    public List<SalesPlan> findAll() {
        try {
            return spDao.findAll();
        } catch (SQLException e) {
            System.out.println("SpServlet的SQL语句出错!");
            throw new RuntimeException(e);
        }
    }

    @Override
    public ResultData list(HttpServletRequest request) {
        return null;
    }

    @Override
    public boolean add(SalesPlan salesPlan) {
        //salesPlan.setPlanner_month(new Date());
        //设置时间
        return spDao.add(salesPlan)>0;
    }

    @Override
    public List<SalesPlan> queryPage(Integer page, Integer limit) {

        //从哪一行开始
        Integer start=(page-1)*limit;
        return spDao.queryPage(start,limit);
    }

    @Override
    public boolean subm(String saleplan_id) {

        return spDao.subm(saleplan_id)>0;
    }

    @Override
    public boolean upData(SalesPlan salesPlan, String saleplan_id) {
        return spDao.upData(salesPlan,saleplan_id)>0;
    }

    @Override
    public boolean del(String saleplan_id) {
        return spDao.del(saleplan_id)>0;
    }

    @Override
    public List<SalesPlan> queryPage(Integer page, Integer limit, String search_name) {
        Integer start=(page-1)*limit;
        return spDao.queryPage(start,limit,search_name);
    }


}
